<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>元素已知宽度</title>
</head>
<style>
    *{
        margin:0 auto;
    }
    html,body{
      width:100%;
      height:100%;  
    }
    .container{
        width:100%;
        height: 100%;
        position: relative;
    }
    .box{
        width:100px;
        height:100px;
        background: orange;
        position:absolute;
        left:0;
        top:0;
        right:0;
        bottom:0;
        margin:auto;    
    }
</style>
<body>
    <div class="container">
        <div class="box">我是居中的盒子</div>
    </div>
</body>
</html>